import React, { Component } from 'react'
import { message } from "antd";
import PropTypes from 'prop-types'
import "./index.css"
export default class Header extends Component {
    static propTypes = {
        addTodo: PropTypes.func.isRequired,
    }
    handleKeyUp = (e) => {
        if (e.keyCode === 13) {
            if (e.target.value.trim() === "") {
                message.info("输入不能为空！");
                return
            }
            this.props.addTodo(e.target.value);
            e.target.value = "";
        }
    }
    render() {
        return (
            <div className="Header">
                <h1>TO DO LIST</h1>
                <input type="text" onKeyUp={this.handleKeyUp} placeholder="plase input what you are going to do" />
            </div>
        )
    }
}
